<template>
<div class="">
  <router-link to="/debate" class="weui_btn weui_btn_warn" style="border-radius: 0">测试页面</router-link>
  <router-link to="/" class="weui_btn weui_btn_plain_default">Home</router-link>
  <router-link to="/debate" class="weui_btn weui_btn_plain_default">Debate</router-link>
  <router-link to="" class="weui_btn weui_btn_plain_default">{{items[0].group_id}}</router-link>
  <router-link to="" class="weui_btn weui_btn_plain_default">{{items[1].group_id}}</router-link>
</div>
</div>
</template>

<script>
import Config from '../config/Config';
import User from '../service/User';
import data from '../data/data.json';
import simRecdata from '../data/simRecdata.json';

export default {
  data() {
    return {
      items: data.items,
      sentenceList: simRecdata.sentenceList,
      groupCount: []
    };
  },
  /**
   * created
   */
  created() {
    console.log('testCreated');
    console.log(Config.getHtmlUrl());

    // 初始化用户信息
    // User.initAccessInfo();
  },
  /**
   * mounted
   */
  mounted() {
    // group count
    console.log('sentenceList', this.sentenceList);
    let groupOne = 0;
    let groupTheOther = 0;

    for (var i = 0; i < this.sentenceList.length; i++) {
      if (this.sentenceList[i] % 2 === 0) {
        groupOne = this.sentenceList[i].likeNum + groupOne;
      } else {
        groupTheOther = this.sentenceList[i].likeNum + groupTheOther;
      }
    }
    groupOne = groupOne + this.sentenceList[0].likeNum;
    groupTheOther = groupTheOther + this.sentenceList[0].likeNum;
    console.log('groupOne', groupOne);
    console.log('groupTheOther', groupTheOther);
    // 整合数据
    console.log('1', this.items);
    console.log('2', this.sentenceList);
    let viewData = [];

    for (let i = 0; i < this.items.length; i++) {
      let item = this.items[i];
      let tempSentence = this.sentenceList.find(function(sentence, index, array) {
        console.log('ssss', sentence.sentenceId);
        console.log('dddd', item.sentence_id);
        return sentence.sentenceId === item.sentence_id;
      });
      // console.log('item', item.sentence_id);

      console.log('tem', tempSentence);
      // item.likeNum = tempSentence.likeNum;

      viewData.push(item);
    }
    // console.log('viewData', viewData);
  }
}
</script>
